package news.service;

import news.util.BaseDao;

/**
 * @author Administrator
 * 更新和删除接口实现类
 */
public class UpdateTopicServiceImpl implements IUpdateTopicService{
    private BaseDao baseDao = new BaseDao();

    @Override
    public void updateTopic(Integer id,String topicName) {
        try {
            baseDao.openDB();
            String sql="update news_topic set topicname=? where id = ?";
            baseDao.ps = baseDao.conn.prepareStatement(sql);
            baseDao.ps.setString(1,topicName);
            baseDao.ps.setInt(2,id);
            baseDao.ps.executeUpdate();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void delTopic(Integer id) {
        try {
            baseDao.openDB();
            String sql = "delete from news_topic where id = ?";
            baseDao.ps = baseDao.conn.prepareStatement(sql);
            baseDao.ps.setInt(1,id);
            baseDao.ps.execute();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
